<?php 
	include_once 'dataservice.php';
	include_once 'thuvienham.php';

	class lophocloai_db 
	{
		public function Them($MaLoaiLop, $TenLoaiLop, $SoTiet, $GhiChu)
		{
			$sql = "INSERT INTO `tbl_lophocloai`(`MaLoaiLop`, `TenLoaiLop`, `SoTiet`, `GhiChu`)
					VALUES ('$MaLoaiLop', '$TenLoaiLop', '$SoTiet', '$GhiChu')";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function Xoa($MaLoaiLop)
		{
			$sql = "DELETE FROM `tbl_lophocloai` WHERE `MaLoaiLop` = '$MaLoaiLop'";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function CapNhat($MaLoaiLop, $TenLoaiLop, $SoTiet, $GhiChu)
		{
			$sql = "UPDATE `tbl_lophocloai`
					SET `TenLoaiLop` = '$TenLoaiLop', `SoTiet` = '$SoTiet', `GhiChu` = '$GhiChu'
					WHERE `MaLoaiLop` = '$MaLoaiLop'";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function LayDanhSach($MaLoaiLop, $TenLoaiLop, $SoTiet, $GhiChu)
		{
			$sql = "SELECT * FROM `tbl_lophocloai` WHERE 1  ";
			if($MaLoaiLop != "")
				$sql .= " AND `MaLoaiLop` = '$MaLoaiLop' ";

			if($TenLoaiLop != "")
				$sql .= " AND `TenLoaiLop` = '$TenLoaiLop' ";

			if($SoTiet != -1)
				$sql .= " AND `SoTiet` = '$SoTiet' ";

			if($GhiChu != "")
				$sql .= " AND `GhiChu` = '$GhiChu' ";

			$service = new dataservice();
			return $service->ExecuteQuery($sql);
		}

	}

